package org.liuyunfeng.service;

import org.liuyunfeng.domain.NewUser;
import org.liuyunfeng.domain.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
public class NewUserService {
    @Autowired
    private UserMapper mapper;

    @Transactional
    public void selectNewUser() throws InterruptedException {
        for (int i = 0; i < 10000; i++) {
            List<NewUser> newUsers = mapper.selectNewUser(20);
            System.out.println(newUsers);
            TimeUnit.SECONDS.sleep(2);
        }

        System.out.println("哈哈哈");
    }

    @Transactional
    public void updateNewUser() throws InterruptedException {
        mapper.updateNewUser20();

        int i = 1 / 0;
    }
}
